package com.woniuxy.purchasemanager.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.woniuxy.commons.entity.purchaseManager.PurchaseOrderEntity;
import com.woniuxy.commons.entity.purchaseManager.dto.PurchaseOrderGoodsEditDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;


/**
 * 采购单表
 *
 * @author huangzhichao
 * @email 1205560871@gmail.com
 * @date 2022-04-19 13:00:28
 */
@Mapper
public interface PurchaseOrderDao extends BaseMapper<PurchaseOrderEntity> {
    /**
     * 分页查询
     * @Author: xianhao
     * @Date: 2022/4/24 19:52
     * @param queryString: 查询条件
     * @param startDate: 开始时间
     * @param endDate: 结束时间
     * @return: com.github.pagehelper.Page<com.woniuxy.commons.entity.purchaseManager.PurchaseOrderEntity>
     **/
    Page<PurchaseOrderEntity> findPageByCondition(@Param("orderNo") String queryString,
                                                  @Param("startDate") Date startDate,
                                                  @Param("endDate") Date endDate);

    /**
     * 获取采购单对应的采购单商品信息
     * @Author: xianhao
     * @Date: 2022/4/25 11:22
     * @param purchaseOrderId:
     * @return: com.woniuxy.commons.entity.purchaseManager.dto.PurchaseOrderGoodsEditDTO
     **/
    PurchaseOrderGoodsEditDTO getPurchaseOrderGoodsEditData(Integer purchaseOrderId);

    /**
     * 删除中间表
     * @Author: xianhao
     * @Date: 2022/4/25 15:07
     * @param splitGoodsId:
     * @return: boolean
     **/
    boolean deleteIntermediateTable(@Param("purchaseOrderId") Integer purchaseOrderId,
                                    @Param("list") List splitGoodsId);

    /**
     * 中间表插入采购单和采购单商品
     * @Author: xianhao
     * @Date: 2022/4/25 16:03s
     * @param purchaseOrderIdNew:
     * @param splitGoodsIds:
     * @return: boolean
     **/
    boolean insertNewMiddleTable(@Param("purchaseOrderIdNew") Integer purchaseOrderIdNew,
                                 @Param("list") List splitGoodsIds);

    /**
     * 查询最新采购单行数据
     * @Author: xianhao
     * @Date: 2022/4/25 17:51
     * @return: java.lang.Integer
     **/
    Integer selectLatestRow();

    /**
     * 插入采购单
     * @Author: xianhao
     * @Date: 2022/4/25 19:04
     * @param purchaseOrderEntity:
     * @return: int
     **/
    int insertPurchaseOrder(PurchaseOrderEntity purchaseOrderEntity);

    /**
     * 查询采购单对应商品数量
     * @Author: xianhao
     * @Date: 2022/4/27 9:52
     * @return: java.lang.Integer
     **/
    Integer selectPurchaseOrderGoodsCount(Integer purchaseOrderId);

    /**
     * 设置取消状态
     * @Author: xianhao
     * @Date: 2022/4/27 9:56
     * @return: void
     **/
    void setCancelStatus(Integer purchaseOrderId);
}
